<?php
include "../inc-config.php";
include "../inc-header.php";
?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="8" height="6px" background="../images/blizzMenu/blue/rb-tleft.gif"><img src="images/btn.gif" width="8" height="6" /></td>
<td background="../images/blizzMenu/blue/top.gif"><img src="images/btn.gif" width="600" height="6" /></td>
<td background="../images/blizzMenu/blue/rb-tright1.gif"><img src="images/btn.gif" width="8" height="6" /></td>
</tr>
<tr>
<td background="../images/blizzMenu/blue/rb-side.jpg" style="background-repeat:repeat-y; background-position:left"  bgcolor="#122031"></td>
<td  bgcolor="#122031" style="color:#FFFFFF">
<?php
print "<link rel='stylesheet' href='usercp.css' type='text/css'>";
if (isset($_SESSION['user']))
{
	$user = $_SESSION['user'];
	$getuser = "SELECT * from b_users a, b_templates b where b.templateid=a.templateclass and a.username='$user'";
	$getuser2 = mysql_query($getuser, $forum) or die("Error #1: " . mysql_error());
	$getuser3 = mysql_fetch_array($getuser2);

	if (isset($_POST['apply']))
	{
		$ranknum = $_POST['ranknum'];

		$SQLwow = "SELECT * from accounts where login='$getuser3[username]'";
		$SQLwow2 = mysql_query($SQLwow, $logon) or die("Error #2: " . mysql_error());
		$SQLwow3 = mysql_fetch_array($SQLwow2);

		$SQLawow = "SELECT * from characters where acct='$SQLwow3[acct]' and guid='$getuser3[charid]'";
		$SQLawow2 = mysql_query($SQLawow, $char) or die("Error #3: " . mysql_error());
		$SQLawow3 = mysql_fetch_array($SQLawow2);

		print "<table class='maintable' align='center' width='600px'>";
		print "<tr class='forumrow'><td><center>";

		$wowrank ="UPDATE characters set pvprank='$ranknum' where name='$SQLawow3[name]'";
		mysql_query($wowrank, $char) or die("Error #4: " . mysql_error());

		print "PVP Rank is now applyed to character $SQLawow3[name].<br> Redirecting to your CP. <META HTTP-EQUIV = 'Refresh' Content = '1; URL =usercp.php'>";
		print "</td></tr></table>";
	}
	else if(isset($_POST['buffme1']))
	{
		$buffid = $_POST['buffid'];
		$getuser = "SELECT * from b_users where username='$user'";
		$getuser2 = mysql_query($getuser, $forum) or die("Error #5: " . mysql_error());
		$getuser3 = mysql_fetch_array($getuser2);
		if ($getuser3['buff'] <= 0)
		{
			print "<center>You dont have buff point's to spend.</center>";
		}
		else
		{
			$SQLwow = "SELECT * from accounts where login = '$getuser3[username]'";
			$SQLwow2 = mysql_query($SQLwow, $logon) or die("Error #6: " . mysql_error());
			$SQLwow3 = mysql_fetch_array($SQLwow2);

			$SQLawow = "SELECT * from characters WHERE acct = '$SQLwow3[acct]' and guid = '$getuser3[charid]'";
			$SQLawow2 = mysql_query($SQLawow, $char) or die("Error #7: " . mysql_error());
			$SQLawow3 = mysql_fetch_array($SQLawow2);

			$point = $getuser3['buff'] - 1;
			$buff = $SQLawow3['auras'].$buffid;

			$wowrank = "UPDATE characters SET auras = '$buff' WHERE name = '$SQLawow3[name]'";
			mysql_query($wowrank, $char) or die("Error #8: " . mysql_error());

			$pointup= "UPDATE b_users set buff='$point' where username='$getuser3[username]'";
			mysql_query($pointup, $forum) or die("Error #9: " . mysql_error());

			print "<center>Buff is now applyed to character $SQLawow3[name].<br> Redirecting to your CP.</center><META HTTP-EQUIV = 'Refresh' Content = '1; URL =usercp.php'>";
		}
	}
	else if (isset($_POST['buffme2']))
	{
		$buffid = $_POST['buffid'];

		$getuser = "SELECT * from b_users where username='$user'";
		$getuser2 = mysql_query($getuser, $forum) or die("Error #10: " . mysql_error());
		$getuser3 = mysql_fetch_array($getuser2);

		if ($getuser3['buff'] <= 0) {
			print "<center>You dont have buff point's to spend.</center>";
		}
		else
		{
			$SQLwow = "SELECT * from accounts where login='$getuser3[username]'";
			$SQLwow2 = mysql_query($SQLwow, $logon) or die("Error #11: " . mysql_error());
			$SQLwow3 = mysql_fetch_array($SQLwow2);

			$SQLawow = "SELECT * from characters where acct='$SQLwow3[acct]' and guid='$getuser3[charid]'";
			$SQLawow2 = mysql_query($SQLawow, $char) or die("Error #12: " . mysql_error());
			$SQLawow3 = mysql_fetch_array($SQLawow2);

			$point = $getuser3['buff']-1;
			$buff = $SQLawow3['auras'].$buffid;

			$wowrank = "UPDATE characters set auras='$buff' where name='$SQLawow3[name]'";
			mysql_query($wowrank, $char) or die("Error #13: " . mysql_error());

			$pointup= "UPDATE b_users set buff='$point' where username='$getuser3[username]'";
			mysql_query($pointup, $forum) or die("Error #14: " . mysql_error());

			print "<center>Buff is now applyed to character $SQLawow3[name].<br> Redirecting to your CP.</center><META HTTP-EQUIV = 'Refresh' Content = '1; URL =usercp.php'>";
		}
	}
	else if (isset($_POST['buffme3']))
	{
		$buffid = $_POST['buffid'];

		$getuser = "SELECT * from b_users where username='$user'";
		$getuser2 = mysql_query($getuser, $forum) or die("Error #15: " . mysql_error());
		$getuser3 = mysql_fetch_array($getuser2);

		if ($getuser3['buff'] <= 0)
		{
			print "<center>You dont have buff point's to spend.</center>";
		}
		else
		{
			$SQLwow = "SELECT * from accounts where login='$getuser3[username]'";
			$SQLwow2 = mysql_query($SQLwow, $logon) or die("Error #16: " . mysql_error());
			$SQLwow3 = mysql_fetch_array($SQLwow2);

			$SQLawow = "SELECT * from characters where acct='$SQLwow3[acct]' and guid='$getuser3[charid]'";
			$SQLawow2 = mysql_query($SQLawow, $char) or die("Error #16: " . mysql_error());
			$SQLawow3 = mysql_fetch_array($SQLawow2);

			$point = $getuser3['buff']--;
			$buff = $SQLawow3['auras'].$buffid;

			$wowrank ="UPDATE characters set auras='$buff' where name='$SQLawow3[name]'";
			mysql_query($wowrank, $char) or die("Error #17: " . mysql_error());

			$pointup= "UPDATE b_users set buff='$point' where username='$getuser3[username]'";
			mysql_query($pointup, $forum) or die("Error #18: " . mysql_error());

			print "<center>Buff is now applyed to character $SQLawow3[name].<br> Redirecting to your CP.</center><META HTTP-EQUIV = 'Refresh' Content = '1; URL =usercp.php'>";
		}
	}
	else if(isset($_POST['buffme4']))
	{
		$buffid = $_POST['buffid'];

		$getuser = "SELECT * from b_users where username='$user'";
		$getuser2 = mysql_query($getuser, $forum) or die("Error #15: " . mysql_error());
		$getuser3 = mysql_fetch_array($getuser2);

		if ($getuser3['buff'] <= 0)
		{
			print "<center>You dont have buff point's to spend.</center>";
		}
		else
		{
			$SQLwow = "SELECT * from accounts where login='$getuser3[username]'";
			$SQLwow2 = mysql_query($SQLwow, $logon) or die("Error #16: " . mysql_error());
			$SQLwow3 = mysql_fetch_array($SQLwow2);

			$SQLawow = "SELECT * from characters where acct='$SQLwow3[acct]' and guid='$getuser3[charid]'";
			$SQLawow2 = mysql_query($SQLawow, $char) or die("Error #16: " . mysql_error());
			$SQLawow3 = mysql_fetch_array($SQLawow2);

			$point = $getuser3['buff']--;
			$buff = $SQLawow3['auras'].$buffid;

			$wowrank ="UPDATE characters set auras='$buff' where name='$SQLawow3[name]'";
			mysql_query($wowrank, $char) or die("Error #17: " . mysql_error());

			$pointup= "UPDATE b_users set buff='$point' where username='$getuser3[username]'";
			mysql_query($pointup, $forum) or die("Error #18: " . mysql_error());

			print "<center>Buff is now applyed to character $SQLawow3[name].<br> Redirecting to your CP.</center><META HTTP-EQUIV = 'Refresh' Content = '1; URL =usercp.php'>";
		}
	}
	else if(isset($_POST['buffme5']))
	{
		$buffid = $_POST['buffid'];

		$getuser = "SELECT * from b_users where username='$user'";
		$getuser2 = mysql_query($getuser, $forum) or die("Error #19: " . mysql_error());
		$getuser3 = mysql_fetch_array($getuser2);

		if ($getuser3['buff'] <= 0)
		{
			print "<center>You dont have buff point's to spend.</center>";
		}
		else
		{
			$SQLwow = "SELECT * from accounts where login='$getuser3[username]'";
			$SQLwow2 = mysql_query($SQLwow, $logon) or die("Error #20: " . mysql_error());
			$SQLwow3 = mysql_fetch_array($SQLwow2);

			$SQLawow = "SELECT * from characters where acct='$SQLwow3[acct]' and guid='$getuser3[charid]'";
			$SQLawow2 = mysql_query($SQLawow, $char) or die("Error #21: " . mysql_error());
			$SQLawow3 = mysql_fetch_array($SQLawow2);

			$point = $getuser3['buff']--;
			$buff = $SQLawow3['auras'].$buffid;

			$wowrank ="UPDATE characters set auras='$buff' where name='$SQLawow3[name]'";
			mysql_query($wowrank, $char) or die("Error #22: " . mysql_error());

			$pointup= "UPDATE b_users set buff='$point' where username='$getuser3[username]'";
			mysql_query($pointup, $forum) or die("Error #23: " . mysql_error());

			print "<center>Buff is now applyed to character $SQLawow3[name].<br> Redirecting to your CP.</center><META HTTP-EQUIV = 'Refresh' Content = '1; URL =usercp.php'>";
		}
	}
	else if(isset($_POST['buffme6']))
	{
		$buffid = $_POST['buffid'];

		$getuser = "SELECT * from b_users where username='$user'";
		$getuser2 = mysql_query($getuser, $forum) or die("Error #24: " . mysql_error());
		$getuser3 = mysql_fetch_array($getuser2);

		if ($getuser3['buff'] <= 0)
		{
			print "<center>You dont have buff point's to spend.</center>";
		}
		else
		{
			$SQLwow = "SELECT * from accounts where login='$getuser3[username]'";
			$SQLwow2 = mysql_query($SQLwow, $logon) or die("Error #25: " . mysql_error());
			$SQLwow3 = mysql_fetch_array($SQLwow2);

			$SQLawow = "SELECT * from characters where acct='$SQLwow3[acct]' and guid='$getuser3[charid]'";
			$SQLawow2 = mysql_query($SQLawow, $char) or die("Error #26: " . mysql_error());
			$SQLawow3 = mysql_fetch_array($SQLawow2);

			$point = $getuser3['buff']--;
			$buff = $SQLawow3['auras'].$buffid;

			$wowrank ="UPDATE characters set auras='$buff' where name='$SQLawow3[name]'";
			mysql_query($wowrank, $char) or die("Error #27: " . mysql_error());

			$pointup= "UPDATE b_users set buff='$point' where username='$getuser3[username]'";
			mysql_query($pointup, $forum) or die("Error #28: " . mysql_error());

			print "<center>Buff is now applyed to character $SQLawow3[name].<br> Redirecting to your CP.</center><META HTTP-EQUIV = 'Refresh' Content = '1; URL =usercp.php'>";
		}
	}
	else if(isset($_POST['buffme7']))
	{
		$buffid = $_POST['buffid'];

		$getuser = "SELECT * from b_users where username='$user'";
		$getuser2 = mysql_query($getuser, $forum) or die("Error #29: " . mysql_error());
		$getuser3 = mysql_fetch_array($getuser2);

		if ($getuser3['buff'] <= 0)
		{
			print "<center>You dont have buff point's to spend.</center>";
		}
		else
		{
			$SQLwow = "SELECT * from accounts where login='$getuser3[username]'";
			$SQLwow2 = mysql_query($SQLwow, $logon) or die("Error #30: " . mysql_error());
			$SQLwow3 = mysql_fetch_array($SQLwow2);

			$SQLawow = "SELECT * from characters where acct='$SQLwow3[acct]' and guid='$getuser3[charid]'";
			$SQLawow2 = mysql_query($SQLawow, $char) or die("Error #31: " . mysql_error());
			$SQLawow3 = mysql_fetch_array($SQLawow2);

			$point = $getuser3['buff']--;
			$buff = $SQLawow3['auras'].$buffid;

			$wowrank ="UPDATE characters set auras='$buff' where name='$SQLawow3[name]'";
			mysql_query($wowrank, $char) or die("Error #32: " . mysql_error());

			$pointup= "UPDATE b_users set buff='$point' where username='$getuser3[username]'";
			mysql_query($pointup, $forum) or die("Error #33: " . mysql_error());

			print "<center>Buff is now applyed to character $SQLawow3[name].<br> Redirecting to your CP.</center><META HTTP-EQUIV = 'Refresh' Content = '1; URL =usercp.php'>";
		}
	}
	else if(isset($_POST['buffme8']))
	{
		$buffid = $_POST['buffid'];

		$getuser = "SELECT * from b_users where username='$user'";
		$getuser2 = mysql_query($getuser, $forum) or die("Error #34: " . mysql_error());
		$getuser3 = mysql_fetch_array($getuser2);

		if ($getuser3['buff'] <= 0)
		{
			print "<center>You dont have buff point's to spend.</center>";
		}
		else
		{
			$SQLwow = "SELECT * from accounts where login='$getuser3[username]'";
			$SQLwow2 = mysql_query($SQLwow, $logon) or die("Error #35: " . mysql_error());
			$SQLwow3 = mysql_fetch_array($SQLwow2);

			$SQLawow = "SELECT * from characters where acct='$SQLwow3[acct]' and guid='$getuser3[charid]'";
			$SQLawow2 = mysql_query($SQLawow, $char) or die("Error #36: " . mysql_error());
			$SQLawow3 = mysql_fetch_array($SQLawow2);

			$point = $getuser3['buff']--;
			$buff = $SQLawow3['auras'].$buffid;

			$wowrank ="UPDATE characters set auras='$buff' where name='$SQLawow3[name]'";
			mysql_query($wowrank, $char) or die("Error #37: " . mysql_error());

			$pointup= "UPDATE b_users set buff='$point' where username='$getuser3[username]'";
			mysql_query($pointup, $forum) or die("Error #38: " . mysql_error());

			print "<center>Buff is now applyed to character $SQLawow3[name].<br> Redirecting to your CP.</center><META HTTP-EQUIV = 'Refresh' Content = '1; URL =usercp.php'>";
		}
	}
	else if(isset($_POST['addmoney']))
	{
		$money0 = $_POST['money'];
		if ($money0 == 0) {
			die("You don't have any money.");
		}
		$getuser = "SELECT * from b_users a, b_templates b where b.templateid=a.templateclass and a.username='$user'";
		$getuser2 = mysql_query($getuser, $forum) or die("Error #39: " . mysql_error());
		$getuser3 = mysql_fetch_array($getuser2);

		if ($getuser3['money'] == 0) {
			print "<center>You don't have any money to tranfer.</center>";
		}
		else
		{
			$SQLwow = "SELECT * from accounts where login='$getuser3[username]'";
			$SQLwow2 = mysql_query($SQLwow, $logon) or die("Error #40: " . mysql_error());
			$SQLwow3 = mysql_fetch_array($SQLwow2);

			$SQLawow = "SELECT * from characters where acct='$SQLwow3[acct]' and guid='$getuser3[charid]'";
			$SQLawow2 = mysql_query($SQLawow, $char) or die("Error #41: " . mysql_error());
			$SQLawow3 = mysql_fetch_array($SQLawow2);

			$money = $SQLawow3['gold'] + $getuser3['money'];

			$wowg ="UPDATE characters set gold='$money' where name='$SQLawow3[name]'";
			mysql_query($wowg, $char) or die("Error #42: " . mysql_error());

			$delg = "UPDATE b_users set money='0' where userID=$getuser3[userID]";
			mysql_query($delg, $forum) or die("Error #43: " . mysql_error());

			print "<center>Money is now transferred to your character $SQLawow3[name].<br> Redirecting to your CP. <META HTTP-EQUIV = 'Refresh' Content = '1; URL =usercp.php'></center>";}
	}
	else if(isset($_POST['submit']))
	{
		function clear($str)
		{
			$str1=str_replace("<", "&lt;", "$str");
			$str2=str_replace(">", "&gt;", "$str1");
			$str3=htmlentities($str2);
			return $str;
		}
		$forumtemplate = $_POST['forumtemplate'];
		$password = $_POST['password1'];
		$password2 = $_POST['password2'];
		$email = clear($_POST['email']);
		$location = clear($_POST['location']);
		$aim = clear($_POST['aim']);
		$icq = clear($_POST['icq']);
		$photo = clear($_POST['photo']);
		$postfont = $_POST['postfont'];
		$postcolor = $_POST['postcolor'];
		$signature = clear($_POST['signature']);
		$char = $_POST['char'];
		$avatar = clear($_POST['avatar']);
		$usepm = $_POST['usepm'];
		$showprofile = $_POST['showprofile'];
		if ($postfont == "no") {
			$postfont = $getuser3['pprof1'];
		}
		if ($postcolor == "no") {
			$postcolor = $getuser3['pprof2'];
		}
		if($_POST['password1'] == $_POST['password2'])
		{
			if($_POST['password1'])
			{
				$password2 = md5($password);
				$deluser2 = "UPDATE accounts set password='$password' where login='$user'";
				mysql_query($deluser2, $logon) or die("Error #44: " . mysql_error());

				$cp = "Update b_users set password='$password2', email='$email',sig='$signature', AIM='$aim', ICQ='$icq',location='$location',showprofile='$showprofile',usepm='$usepm',avatar='$avatar',photo='$photo',templateclass='$forumtemplate',charid='$char',pprof1='$postfont', pprof2='$postcolor' where username='$user'";
				mysql_query($cp, $forum) or die("Error #45: " . mysql_error());
			}
			else if(strlen($email) < 4 || substr_count($email," ") > 0)
			{
				die("You did not enter an email");
			}
			else
			{
				$cp = "Update b_users set email='$email',sig='$signature',AIM='$aim', ICQ='$icq',location='$location',showprofile='$showprofile',usepm='$usepm',avatar='$avatar',photo='$photo',templateclass='$forumtemplate',charid='$char',pprof1='$postfont', pprof2='$postcolor' where username='$user'";
				mysql_query($cp, $forum) or die("Error #46: " . mysql_error());
			}
			print "<table class='maintable' align='center' width='600px'>";
			print "<tr class='forumrow'><td><center>";
			print "Details updated, redirecting to your CP. <META HTTP-EQUIV = 'Refresh' Content = '1; URL =usercp.php'>";
			print "</td></tr></table>";
		}
		else if(!$_POST['email'])
		{
			print "<table class='maintable' align='center' width='600px'>";
			print "<tr class='forumrow'><td><center>";
			print "No e-mail value entered, please hit back and try again.";
			print "</td></tr></table>";
		}
		else
		{
			print "<table class='maintable' align='center'>";
			print "<tr class='forumrow'><td><center>";
			print "<table border='0'><tr class='forumrow'><td>";
			print "Passwords did not match, please try again<br>";
			print "</td></tr></table></td></tr></table>";
		}
	}
	else
	{
		print "<center><br><span style='font-size: 18px; font-family:Century Gothic, Arial, Helvetica; color:#ffffff' >$user's Control Panel</span><br><br>";
		print "<table align='center' width='680px' border='0'>";
		print "<tr><td width='40%' valign='top' align='center' class='user2'>";
		print "<a href='index.php'>Go Forum</a> | <a href='../home.php'>Go Main Page</a> | <a href='../shop.php'>Shopping</a><br>";
		print "<div class='user'>";

		$userselect = "SELECT * from b_users where username='$user'";
		$userselect2 = mysql_query($userselect, $forum) or die("Error #47: " . mysql_error());
		$userselect3 = mysql_fetch_array($userselect2);

		$SQLwow = "SELECT * from accounts where login='$userselect3[username]'";
		$SQLwow2 = mysql_query($SQLwow, $logon) or die("Error #48: " . mysql_error());
		$SQLwow3 = mysql_fetch_array($SQLwow2);

		$SQLawow = "SELECT * from characters where acct='$SQLwow3[acct]' and guid='$userselect3[charid]'";
		$SQLawow2 = mysql_query($SQLawow, $char) or die("Error #49: " . mysql_error());
		$SQLawow3 = mysql_fetch_array($SQLawow2);

		if ($SQLawow3['name'] <> '') {
			print "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
			print "<tr><td>";
			print "<form action='usercp.php' method='post'>";
			print "<input type='hidden' name='buffid' value='23948,3484000,'>";
			print "<input type='submit' name='buffme1' value='' class='sta'>";
			print "</form>";
			print "</td>";
			print "<td>";
			print "<form action='usercp.php' method='post'>";
			print "<input type='hidden' name='buffid' value='16876,3419000,'>";
			print "<input type='submit' name='buffme2' value='' class='int' >";
			print "</form>";
			print "</td>";
			print "<td>";
			print "<form action='usercp.php' method='post'>";
			print "<input type='hidden' name='buffid' value='17539,3590000,'>";
			print "<input type='submit' name='buffme3' value=''class='spell'>";
			print "</form>";
			print "</td>";
			print "<td>";
			print "<form action='usercp.php' method='post'>";
			print "<input type='hidden' name='buffid' value='28491,3531000,'>";
			print "<input type='submit' name='buffme5' value='' class='heal'>";
			print "</form>";
			print "</td>";
			print "<td>";
			print "<form action='usercp.php' method='post'>";
			print "<input type='hidden' name='buffid' value='28502,3592000,'>";
			print "<input type='submit' name='buffme4' value='' class='armor'>";
			print "</form>";
			print "</td>";
			print "<td>";
			print "<form action='usercp.php' method='post'>";
			print "<input type='hidden' name='buffid' value='28520,3449000,'>";
			print "<input type='submit' name='buffme6' value='' class='power'>";
			print "</form>";
			print "</td>";
			print "<td>";
			print "<form action='usercp.php' method='post'>";
			print "<input type='hidden' name='buffid' value='36001,3542000,'>";
			print "<input type='submit' name='buffme7' value='' class='mele'>";
			print "</form>";
			print "</td>";
			print "<td>";
			print "<form action='usercp.php' method='post'>";
			print "<input type='hidden' name='buffid' value='35874,3542000,'>";
			print "<input type='submit' name='buffme8' value='' class='magic'>";
			print "</form>";
			print "</td>";
			print "</tr></table>";
			print $userselect3['buff']." buff points left. <a href='buffhelp.php'>Help?</a><br><br>";
		}
		else
		{
			print "<br /><br />";
		}
		if ($userselect3['avatar'] == "")
		{
			if ($userselect3['charid'] == 0)
			{
				print "<div style='height: $avatarheight;'>[No Avatar]</div>";
			}
			else
			{
				if ($SQLawow3['level'] <= 50)
				{
					print "<img style='border:double 3px #000000' src='".$boardpath."avatars/wow-default/$SQLawow3[gender]-$SQLawow3[race]-$SQLawow3[class].gif' height='$avatarheight' width='$avatarwidth' border='0' class='avatar'>";
				}
				elseif ($SQLawow3['level'] >= 51 && $SQLawow3['level'] <= 69)
				{
					print "<img style='border:double 3px #000000' src='".$boardpath."avatars/wow/$SQLawow3[gender]-$SQLawow3[race]-$SQLawow3[class].gif' height='$avatarheight' width='$avatarwidth' border='0' class='avatar'>";
				}
				else
				{
					print "<div align='center'><img style='border:double 3px #000000' src='".$boardpath."avatars/wow-70/$SQLawow3[gender]-$SQLawow3[race]-$SQLawow3[class].gif' height='$avatarheight' width='$avatarwidth' border='0' class='avatar'></div>";
				}
			}
		}
		else
		{
			print "<img style='border: double 3px #000000;' src='$userselect3[avatar]' height='$avatarheight' width='$avatarwidth' border='0' class='avatar'>";}
			print "<br /><br />";
			if ($userselect3['charid'] == 0)
			{
				print "[No character selected]<div style='margin:6px'></div>";
			}
			else
			{
				if ($SQLawow3['race'] == 1 || $SQLawow3['race'] == 3 || $SQLawow3['race'] == 4 || $SQLawow3['race'] == 7 || $SQLawow3['race'] == 11)
				{
					$side = 0;
				}
				else
				{
					$side = 1;
				}
				print "<strong>$SQLawow3[name]</strong> Level $SQLawow3[level]<br><br><img src='images/pvpranks/rank_default_$side.gif' title='Side' /> <img src='images/race/$SQLawow3[race]-$SQLawow3[gender].gif' title='Race' />&nbsp;&nbsp;<img src='images/class/$SQLawow3[class].gif' title='Class' />&nbsp;&nbsp;<img src='images/pvpranks/rank$SQLawow3[pvprank].gif' title='Rank' />";
				$gold = substr($SQLawow3['gold'], 0, -4);
				if ($gold=='')
				{
					$gold = 0;
				}
				$silver = substr($SQLawow3['gold'], 0, -2);
				$silver2 = substr($silver, -2);
				if ($silver2 == '')
				{
					$silver2="0";
				}
				$copper = substr($SQLawow3['gold'], -2);
				if ($copper == '')
				{
					$copper="0";
				}
				print "<BR><br>Money: $gold <img src='images/pvpranks/money_gold.gif' />&nbsp;&nbsp;$silver2 <img src='images/pvpranks/money_silver.gif' />&nbsp;&nbsp;$copper <img src='images/pvpranks/money_copper.gif' />";
				if ($SQLawow3['pvprank'] <> $userselect3['ranknum']) {
					print "<form action='usercp.php' method='post'>";
					print "<input type='hidden' name='ranknum' value='$userselect3[ranknum]'><br>";
					print "<input type='submit' name='apply' value='Apply Rank'>";
					print "<font size='1'><br>Make sure you are not playing with character when you applying.</font>";
					print "</form>";
				}
			}
			print "</div>";
			print "<div class='user'>";
			print "<font size='4' color='#ffffff'><strong>$userselect3[username]</strong></font><br>";
			print "&lt;$userselect3[ranktitle]&gt;<br><br>";
			print "<strong>$userselect3[points]</strong> Points available to spend.<br><br>";
			print "You have <strong>$userselect3[honours]</strong> rep.<br><br>";
			print "You have posted <strong>$userselect3[posts]</strong> times.";
			$gold = substr($userselect3['money'], 0, -4);
			if ($gold == '')
			{
				$gold = 0;
			}

			$silver = substr($userselect3['money'], 0, -2);
			$silver2 = substr($silver, -2);

			if ($silver2 == '') {
				$silver2 = 0;
			}
			$copper = substr($userselect3['money'], -2);
			if ($copper == '' || $copper == 00)
			{
				$copper = 0;
			}
			print "<br /><br />Bank: $gold <img src='images/pvpranks/money_gold.gif' />&nbsp;&nbsp;$silver2 <img src='images/pvpranks/money_silver.gif' />&nbsp;&nbsp;$copper <img src='images/pvpranks/money_copper.gif' />";
			if ($userselect3['money'] <> 0 && $userselect3['charid'] <> 0) {
				print "<br><br><form action='usercp.php' method='post'>";
				print "<input name='money' type='hidden' value='$userselect3[money]' />";
				print "<input name='addmoney' type='submit' value='Tranfer Money' /><br>";
				print "<font size='1'>You MUST be logged out of game so this can work, otherwise you will loose your money.</font>";
				print "</form>"; }
				print "<div style='margin:6px'></div></div>";
				print "<a href='rep.php'>Point and reputation system</a><br><br>";
				print "<a href='profile.php?userID=$userselect3[userID]'>My Public Profile</a> | <a href='logout.php'>Logout</a>";

				switch ($userselect3['honours']) {
					case ($userselect3['honours'] <= 99):
						$rankttitle1 = 'No Rank';
						$rankttitle2 = 'No Rank';
						$rank = '0';
						break;
					case ($userselect3['honours'] <= 149):
						$rankttitle1 = 'Private';
						$rankttitle2 = 'Scout';
						$rank = '1';
						break;
					case ($userselect3['honours'] <= 199):
						$rankttitle1 = 'Corporal';
						$rankttitle2 = 'Grunt';
						$rank = '2';
						break;
					case ($userselect3['honours'] <= 349):
						$rankttitle1 = 'Sergeant';
						$rankttitle2 = 'Sergeant';
						$rank = '3';
						break;
					case ($userselect3['honours']<=449):
						$rankttitle1 = 'Master Sergeant';
						$rankttitle2 = 'Senior Sergeant';
						$rank = '4';
						break;
					case ($userselect3['honours'] <= 599):
						$rankttitle1 = 'Sergeant Major';
						$rankttitle2 = 'First Sergeant';
						$rank = '5';
						break;
					case ($userselect3['honours'] <= 749):
						$rankttitle1 = 'Knight';
						$rankttitle2 = 'Stone Guard';
						$rank = '6';
						break;
					case ($userselect3['honours'] <= 899):
						$rankttitle1 = 'Knight-Lieutenant';
						$rankttitle2 = 'Blood Guard';
						$rank = '7';
						break;
					case ($userselect3['honours'] <= 1099):
						$rankttitle1 = 'Knight-Captain';
						$rankttitle2 = 'Legionnare';
						$rank = '8';
						break;
					case ($userselect3['honours']<=1299):
						$rankttitle1 = 'Knight-Champion';
						$rankttitle2 = 'Centurion';
						$rank = '9';
						break;
					case ($userselect3['honours'] <= 1599):
						$rankttitle1 = 'Lieutenant Commander';
						$rankttitle2 = 'Champion';
						$rank = '10';
						break;
					case ($userselect3['honours'] <= 1799):
						$rankttitle1 = 'Commander';
						$rankttitle2 = 'Lieutenant General';
						$rank = '11';
						break;
					case ($userselect3['honours'] <= 2199):
						$rankttitle1 = 'Marshal';
						$rankttitle2 = 'General';
						$rank = '12';
						break;
					case ($userselect3['honours'] <= 2999):
						$rankttitle1 = 'Field Marshal';
						$rankttitle2 = 'Warlord';
						$rank = '13';
						break;
					case ($userselect3['honours'] <= 999990000):
						$rankttitle1 = 'Grand Marshal';
						$rankttitle2 = 'High Warlord';
						$rank = '14';
						break;
					default:
						$rankttitle1 = 'No Rank';
						$rankttitle2 = 'No Rank';
						$rank = '0';
				}
				if ($side == 0)
				{
					$rankt = $rankttitle1;
					if ($rankt <> $userselect3['ranktitle'])
					{
						$updatee = "UPDATE b_users SET ranktitle='$rankttitle1' where username='$user'";
						$updatee2 = mysql_query($updatee, $forum) or die("Error #50: " . mysql_error());
						print "<br /><br /><span style='color:#00CC00'><strong>Rank side changed to alliance.</strong></span>";
					}
				}
				else
				{
					$rankt = $rankttitle2;
					if ($rankt <> $userselect3['ranktitle'])
					{
						$updatee = "UPDATE b_users SET ranktitle='$rankttitle2' where username='$user'";
						$updatee2 = mysql_query($updatee, $forum) or die("Error #51: " . mysql_error());
						print "<br /><br /><span style='color:#00CC00'><strong>Rank side changed to horde.</strong></span>";
					}
				}
				if ($rank <> $userselect3['ranknum'])
				{
					$updaterank = "UPDATE b_users SET ranktitle='$rankt', ranknum='$rank' where username='$user'";
					$updaterank2 = mysql_query($updaterank, $forum) or die("Error #52: " . mysql_error());
					print "<br /><br /><span style='color:#00CC00'><strong>You have been promoted to $rankt! Congratulations!<br>Reload this page.</strong></span>";
				}
				print "</td><td width='60%'><center>";
				print "<table border='0'><tr><td class='user2'>";
				print "<form action='usercp.php' method='post'>";
				print "<input type='hidden' name='username' value='$userselect3[user]'><br>";
				print "<div class='user' style='text-align:left'>";
				print "New Password:<br><input type='password' name='password1' style='width:300px'><br>";
				print "Re-type password:<br><input type='password' name='password2' style='width:300px'><br>";
				print "Use PMs? <font size='1'>(recommended Yes)</font><br>";
				print "<select name='usepm'>";
				if ($userselect3['usepm'] == 0)
				{
					print "<option value='1'>Yes</option>";
					print "<option selected='selected' value='0'>No</option>";
				}
				else {
					print "<option selected='selected' value='1'>Yes</option>";
					print "<option value='0'>No</option>";
				}
				print "</select><br>";
				print "Your email: <font size='1'>(hidden in public profile)</font><br>";
				print "<input type='text' name='email' size='15' value='$userselect3[email]' style='width:300px'><br>";
				print "</div>";
				print "<div class='user' style='text-align:left'>";
				print "Location:<br>";
				print "<input type='text' name='location' size='15' value='$userselect3[location]' style='width:300px'><br>";
				print "MSN:<br>";
				print "<input type='text' name='aim' size='15' value='$userselect3[AIM]' style='width:300px'><br>";
				print "Show Profile:<br>";
				print "<select name='showprofile'>";
				if ($userselect3['showprofile'] == 0)
				{
					print "<option value='1'>Yes</option>";
					print "<option selected='selected' value='0'>No</option>";
				}
				else
				{
					print "<option selected='selected' value='1'>Yes</option>";
					print "<option value='0'>No</option>";}
					print "</select><br>";
					print "</div>";
					print "<div class='user' style='text-align:left'>";
					print "URL of Avatar: <font size='1'>(always $avatarheight x $avatarwidth)</font><br>";
					if ($userselect3['honours']<=49)
					{
						print "<br />[This option is locked! Gain 50 rep to unlock it.]<br><br>";
					}
					else
					{
						print "<input type='text' name='avatar' size='40' value='$userselect3[avatar]' style='width:300px'><br>";
					}
					print "URL of your Photo:<font size='1'> <font color='orange'>*new</font><br>(shown in your public profile,<br>scaled to max 200 width and height)</font><br>";
					print "<input type='text' name='photo' size='40' value='$userselect3[photo]' style='width:300px'><br>";
					print "Forum Template:<br>";
					print "<select name='forumtemplate'>";
					print "<option value='$getuser3[templateid]'>$getuser3[templatepath]</option>";

					$gettemplates = "SELECT * from b_templates where templateid!='1' order by templateid desc";
					$gettemplates2 = mysql_query($gettemplates, $forum) or die("Error #53: " . mysql_error());

					while($gettemplates3 = mysql_fetch_array($gettemplates2))
					{
						print "<option value='$gettemplates3[templateid]'>$gettemplates3[templatepath]</option>";
					}
					print "</select><br>";
					print "</div>";
					print "<div class='user' style='text-align:left'>";
					print "Select font for your posts:<br><font size='1'>(now selected: $getuser3[pprof1])</font><br>";
					print "<select name='postfont'>";
					print "<option value='no'>No Change</option>";
					print "<option value='Verdana, Arial, Helvetica, sans-serif' style='font-family:Verdana, Arial, Helvetica, sans-serif'>Verdana (default)</option>";
					print "<option value='Arial, Helvetica, sans-serif' style='font-family:Arial, Helvetica, sans-serif'>Arial</option>";
					print "<option value='Tahoma, Arial, Vedrana, sans-serif' style='font-family:Tahoma, Arial, Vedrana, sans-serif'>Tahoma</option>";
					print "<option value='Comic Sans MS, Vedrana, sans-serif' style='font-family:Comic Sans MS, Vedrana, sans-serif'>Comic Sans MS</option>";
					print "<option value='Times New Roman, Times, serif' style='font-family:Times New Roman, Times, serif'>Times New Roman</option>";
					print "<option value='Courier New, Courier, monospace' style='font-family:Courier New, Courier, monospace'>Courier New</option>";
					print "<option value='Lucida Console, Verdana, sans-serif' style='font-family:Lucida Console, Verdana, sans-serif'>Lucida Console</option>";
					print "<option value='Century Gothic, Verdana, sans-serif' style='font-family:Century Gothic, Verdana, sans-serif'>Century Gothic</option>";
					print "<option value='Impact, Verdana, sans-serif' style='font-family:Impact, Verdana, sans-serif'>Impact</option>";
					print "<option value='Morpheus, Verdana, sans-serif' style='font-family:Morpheus, Verdana, sans-serif'>WoW Font (not many have it, dl below)</option>";
					print "</select><br>";
					print "<a href='../downloads/MORPHEUS.TTF'><font size='1'>Download WoW font (Morpheus.ttf)</font></a><br>";
					print "Select font color for your posts:<br><font size='1'>(now selected: $getuser3[pprof2])</font><br>";
					print "<select name='postcolor'>";
					print "<option value='no'>No Change</option>
					<option value='#cccccc' style='color:#cccccc'>Silver (Default)</option>
					<option value='red' style='color:red'>Red</option>
					<option value='fuchsia' style='color:fuchsia'>Fuchsia</option>
					<option value='lightblue' style='color:lightblue'>Light Blue</option>
					<option value='aqua' style='color:aqua'>Aqua</option>
					<option value='teal' style='color:teal'>Teal</option>
					<option value='lime' style='color:lime'>Lime</option>
					<option value='green' style='color:green'>Green</option>
					<option value='olive' style='color:olive'>Olive</option>
					<option value='yellow' style='color:yellow'>Yellow</option>
					<option value='white' style='color:white'>White</option>";
					print "</select><br>";
					print "</div>";
					print "<div class='user' style='text-align:left'>";
					if ($userselect3['honours'] <= 4) {
						print "Signature: <font size='1'>(255chars, html off, BBCode on)</font><br> [This option is locked! Gain 5 rep to unlock it.]<br><br>";
					}
					else
					{
						print "Signature: <font size='1'>(255 chars, html off, BBCode on)</font><br>";
						print "<textarea name='signature' rows='5' cols='30'>$userselect3[sig]</textarea><br>";
					}

					$SQLwow = "SELECT * from accounts where login='$userselect3[username]'";
					$SQLwow2 = mysql_query($SQLwow, $logon) or die("Error #54: " . mysql_error());
					$SQLwow3 = mysql_fetch_array($SQLwow2);
					$accid = $SQLwow3['acct'];

					$SQLawow ="SELECT * from characters where acct='$accid'";
					$SQLawow2=mysql_query($SQLawow, $char) or die("Error #55: " . mysql_error());
					if ($userselect3['charid'] == 0)
					{
						$char = "none";
					}
					else
					{
						$char = $SQLawow3['name']." lvl ".$SQLawow3['level'];
					}
					print "Select Character:<br><font size='1'>(now selected $char)</font><br>";
					print "<select name='char'>";
					print "<option value='0'>(No Character)</option><br>";
					$dd = 0;
					while ($SQLawow3 = mysql_fetch_array($SQLawow2))
					{
						if ($SQLawow3['guid'] == $userselect3['charid'])
						{
							print "<option selected='selected' value='$SQLawow3[guid]'>-> $SQLawow3[name] lvl $SQLawow3[level]</option>";
						}
						else if ($SQLawow3['guid'] <> $userselect3['charid'])
						{
							print "<option value='$SQLawow3[guid]'>$SQLawow3[name] lvl $SQLawow3[level]</option><br>";
						}
						if ($userselect3['charid'] <> $SQLawow3['guid'])
						{
							if ($userselect3['charid'] == 0)
							{
								$dd -= 50;
							}
							else
							{
								$dd++;
							}
						}
						else
						{
							$dd -= 50;
						}
					}
					if ($dd >= -10)
					{
						print "<option selected='selected' value='0'>Character Deleted</option>";
						$updatechar = "UPDATE b_users SET charid='0' where username='$user'";
					}
					print "</select><br>";
					if ($dd >= -10)
					{
						mysql_query($updatechar, $forum) or die("Error #56: " . mysql_error());
						print "<br><strong><span style='color:#FF0000'>Or you have deleted selected character ingame, <br>or you don't have any characters.<br></span>Select new character and update profile.<br>This message will go away when u create character ingame.</strong>";
					}
					print "</div>";
					print "<br><input type='submit' name='submit' value='change details'>";
					print "</form>";
					print "</td></tr></table></td></tr></table>";
	}
}
else
{
	print "<table class='maintable' align='center' width='600px'>";
	print "<tr class='headline'><td><center>User CP</center></td></tr>";
	print "<tr class='forumrow'><td><center>";
	print "Not logged in, please <A href='login.php'>Go here</a> to log in";
	print "</td></tr></table>";
}
?>
</td>
<td width="8"  background="../images/blizzMenu/blue/rb-side.jpg" style="background-repeat:repeat-y; background-position:right" bgcolor="#122031"></td>
</tr>
<tr>
<td height="6px" background="../images/blizzMenu/blue/rb-bleft.gif"></td>
<td  background="../images/blizzMenu/blue/bot.gif"></td>
<td background="../images/blizzMenu/blue/rb-bright1.gif"></td>
</tr>
</table>
<?php
include "../inc-footer.php";
?>